package main

import (
	"fmt"
	"github.com/golang/protobuf/proto"
	"net/rpc"
	"rpc_proto/message"
)

func main(){
	orderRequest := message.OrderRequest{
		OrderId:*proto.Int64(1),
		TimeStamp:*proto.String("2020-8-18 21:11:20"),
	}
	//序列化请求参数，打成二进制
	data,err := proto.Marshal(&orderRequest)
	if err!=nil{
		panic(err)
	}

	//通过rpc调用远程服务器方法执行
	client,err := rpc.DialHTTP("tcp",":8081")
	if err!=nil{
		panic(err)
	}
	var orderIndo *message.OrderInfo
	//同步请求
	err = client.Call("ServerOrder.GetOrderInfo",data,&orderIndo)
	if err!=nil{
		panic(err)
	}
	fmt.Println("client端收到订单信息:",*orderIndo)
}
